package org.crazyit.activiti_d4._7_ProcessDefinitionQuery;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.ProcessDefinition;

import java.util.List;

public class ProcessDefinitionQuery {

    public static void main(String[] args) {

        //1. 创建流程引擎
        ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();

        //2. 得到流程存储服务实例
        RepositoryService repositoryService = engine.getRepositoryService();

        /**
         * 由于上个类已经新增过数据, 这边直接查询
         */

        //3. startableByUser 方法
        List<ProcessDefinition> defAQuery = repositoryService.createProcessDefinitionQuery().startableByUser("7f09e69c-bd13-4fd7-ade7-c388e98259cc").list();
        for (ProcessDefinition processDefinition : defAQuery) {
            System.out.println("根据用户ID 为7f09e69c-bd13-4fd7-ade7-c388e98259cc 查询该用户有权限的启动流程定义:" + processDefinition.getName());
        }

    }

}
